package com.sf;

public class CustomStack<T> {
    private StackNode<T> top;
    private int size;

    public CustomStack() {
        top = null;
        size = 0;
    }

    public void push(T data) {
        StackNode<T> node = new StackNode<T>(data);
        node.next = top;
        top = node;
        size++;

    }

    public T pop() {
        T data = top.data;
        top = top.next;
        size--;
        return data;
    }

    public void printAll() {
        while(top!=null) {
            System.out.println(top.data);
            top = top.next;
        }
    }
}
